using System;
using Microsoft.VisualStudio.CodeCoverage;

namespace CoverageRunner
{
    public class Runner : IDisposable
    {
        private readonly Monitor monitor;
        private readonly Guid runnerGuid = Guid.NewGuid();

        public Runner(string vstsCoverageOutputFile)
        {
            monitor = new Monitor();
            monitor.StartRunCoverage(runnerGuid, vstsCoverageOutputFile);
        }

        public void Dispose()
        {
            if (monitor != null) monitor.FinishRunCoverage(runnerGuid);
        }
    }
}